import api from '@/api';
let $api = api.studentScore

const actions = {
  // 获取分页后的成绩信息
  async getFindPageStudentScore({commit},{currentPage,limit}){
    let result = await $api.reqFindPageStudentScore(currentPage,limit)
    if(result.code === 200){
      return result
    }else{
      return Promise.reject(new Error('fail'))
    }
  },
  // 根据姓名获取成绩
  async getFindStudentName({commit},studentName){
    let result = await $api.reqFindStudentName(studentName)
    if(result.code === 200){
      return result
    }
  },
  // 根据课程和分数查询成绩
  async getFindStudentSubjectScore({commit},{subject,score}){
    let result = await $api.reqFindStudentSubjectScore(subject,score)
    if(result.code === 200){
      return result
    }
  },
  // 获取添加或的修改成绩信息
  async getAddOrUpdateStudentScore({commit},scoreInfo){
    let result = await $api.reqAddOrUpdateStudentScore(scoreInfo)
    if(result.code === 200){
      return result
    }
  },
  // 获取删除成绩信息
  async getDeleteStudentScore({commit},scoreId){
    let result = await $api.reqDeleteStudentScore(scoreId)
    if(result.code === 200) {
      return result
    }
  },
  // 获取批量删除成绩信息
  async getBatchDeleteStudentScore({commit},scoreIdArr){
    let result = await $api.reqBatchDeleteStudentScore(scoreIdArr)
    if(result.code === 200) {
      return result
    }
  }
}
const mutations = {}
const state = {}
const getters = {}

export default {
  namespaced:true,
  actions,
  mutations,
  state,
  getters
}